<template>
	<view>
		<u-popup :show="popshow" @close="close" :closeable="true" :safeAreaInsetBottom="false" mode="center" :round="10">
			<view class="pop-main">
				<view class="pop-title">订单申请改价</view>
				<view class="pop-box" :style="'height:'+ pop_height">
					<u-cell-group>
						<u-cell title='订单编号' :value="order.order_sn" :titleStyle="titleStyle"></u-cell>
						<u-cell title='订单金额' :value="order.real_money" :titleStyle="titleStyle"></u-cell>
						<u-cell>
							<view slot="title" class="cell-title">申请金额</view>
							<view slot="value">
								<input v-model="post.money" class="form-input" placeholder="申请金额"/>
							</view>
						</u-cell>
						<view class="discount-content">
							<u-textarea v-model="post.content" placeholder="申请原因" ></u-textarea>
						</view>
					</u-cell-group>
				</view>
				<view class="pop-foot">
					<button class="my-but-primary" @click="submit()">确定</button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		data() {
			return {
				popshow:false,
				order:{},
				titleStyle:{'font-size': '30rpx'},
				post:{				//添加信息
					order_id:0,
					money:'',
					content:'',
				}
			};
		},
		watch: {
		},
		computed: {
			...mapState({
				$config:state => state.$config,
				$s:state => state.$style,
			})
		},
		onReady(){
		},
		mounted() {
		},
		methods: {
			submit(){
				if(!this.post.money){
					this.$c.info('请输入要修改的金额')
				}else{
					this.$u.api.applyDiscount(this.post).then(res=>{
						this.$c.success('申请成功！等待管理员审核')
						this.popshow=false
						
						let than=this
						setTimeout(function() {
							than.$emit('success',true)
						},1300);
					})
				}
			},
			show(id){
				this.post.order_id=id
				this.$u.api.orderInfo({order_id:id}).then(res=>{
					this.order=res.data.order
					this.post.money=this.order.real_money
					this.popshow=true
				})
			},
			close(){
				this.popshow=false
			}
		}
	};
</script>

<style lang="scss">
	.pop-main{
		width: 660rpx;
	}
	.pop-box{
		padding:40rpx 20rpx;
	}
	.form-input{
		font-size: 30rpx;
		border: 1px solid $u-border-color;
		border-radius: 10rpx;
		padding: 10rpx 20rpx;
	}
	.cell-title{
		font-size: 30rpx;
		width: 120rpx;
	}
	.cell-value{
		text-align: right;
		width: 420rpx;
		font-size: 30rpx;
	}
	.no-select{
		color: $u-tips-color;
	}
	.discount-content{
		margin-top: 20rpx;
	}
</style>
